package com.example.dllo.exe.giftspeak.jingxuan;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.dllo.exe.bean.JingXuanTurnBean;
import com.example.dllo.exe.R;
import com.squareup.picasso.Picasso;

/**
 * code is far away from bug with the animal protecting
 * <p>
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃永无BUG！  凯哥 祝你一路顺风
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 */
public class JingXuanTurnPagerAdapter extends PagerAdapter {
    private JingXuanTurnBean imags;
    private Context context;

    private ImageView[] tips;

    public void setTips(ImageView[] tips) {
        this.tips = tips;
    }

    private int cont = 1;


    public JingXuanTurnPagerAdapter(Context context) {
        this.context = context;

    }

    public void setImags(JingXuanTurnBean imags) {
        this.imags = imags;
        cont = imags.getData().getBanners().size();

    }




    @Override
    public int getCount() {
        return imags != null ? Integer.MAX_VALUE : 0;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        View view = LayoutInflater.from(context).inflate(R.layout.jingxuanturnpagerfragmentlayout, null);
        ImageView JingXuanImageView = (ImageView) view.findViewById(R.id.jingxuan_image_view);
        Picasso.with(context).load(imags.getData().getBanners().get(position % cont).getImage_url()).into(JingXuanImageView);
        container.addView(view);

        return view;


    }


    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }




}
